package com.example.demo.controller;

import com.example.demo.pojo.ClassificationTable;
import com.example.demo.service.ClsssificationTable;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(value = "分类管理",tags = "分类管理")
@RequestMapping("/classify")
public class ClassificationTableController {
    @Autowired
    ClsssificationTable clsssificationTable;

    @RequestMapping(value = "/add",method = RequestMethod.GET)
    @ApiOperation(value = "分类增加",notes = "分类增加")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "descriptionofspecies",value = "分类说明"),
            @ApiImplicitParam(name = "pid",value = "父类id")
    })
    public String addClassify(ClassificationTable classificationTable){
        int decide=clsssificationTable.add(classificationTable);
        if(decide>0){
            return "增加成功";
        }else{
            return "增加失败";
        }
    }



    @RequestMapping(value = "/update",method = RequestMethod.GET)
    @ApiOperation(value = "分类修改",notes = "分类修改")
    @ApiImplicitParam(name = "classificationid",value = "分类id")
    public String deleteClassfiy(int classificationid,String  descriptionofspecies){
        ClassificationTable classificationTable1=new ClassificationTable();
        classificationTable1.setClassificationid(classificationid);
        classificationTable1.setDescriptionofspecies(descriptionofspecies);
        int decide=clsssificationTable.update(classificationTable1);
        if(decide>0){
            return "操作成功";
        }else {
            return "操作失败";
        }


    }

}
